<!doctype html>
<html>
<head>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
<title>宏博预约</title>
<link href="../../css/newStyle.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../../js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script type="text/javascript" src="../../js/openId.js"></script>
<script type="text/javascript" src="../../js/check.js"></script>
<script type="text/javascript" src="../../js/header&footer.js"></script>
<link href="../../css/mobiscroll.custom-2.6.2.min.css" rel="stylesheet" type="text/css" />
<script src="../../js/mobiscroll.custom-2.6.2.min.js" type="text/javascript"></script>
<script type="text/javascript" src="../../js/qmsk-1.1.js"></script>
<script type="text/javascript" src="../../js/utils.js"></script>

<!--时间插件-->
<script type="text/javascript">
var memberId=0;
$(function () {
	$("input").attr("disabled",false)
	var curr = new Date().getFullYear();
	var opt = {

	}
	opt.date = {preset : 'date'};
opt.datetime = { preset : 'datetime', minDate: new Date(1940,3,10,9,22), maxDate: new Date(2099,7,30,15,44), stepMinute: 5  };
opt.time = {preset : 'time'};
opt.tree_list = {preset : 'list', labels: ['Region', 'Country', 'City']};
opt.image_text = {preset : 'list', labels: ['Cars']};
opt.select = {preset : 'select'};
	$('select.changes').bind('change', function() {
		var demo = $('#demo').val();
		$(".demos").hide();
		if (!($("#demo_"+demo).length))
			demo = 'default';

		$("#demo_" + demo).show();
		$('#test_'+demo).val('').scroller('destroy').scroller($.extend(opt[$('#demo').val()], { theme: $('#theme').val(), mode: $('#mode').val(), display: $('#display').val(), lang: 'Chinese' }));
	});

	$('#demo').trigger('change');
	
	var  member=_findInfo("../../../member/find/shopId/"+getShopId()+"/openId/"+getOpenId(), null)
	if(IsNotEmpty(member)&&member.state==0){
		if(member.result.data.length>0){
		$("#name").val(getHtmlString(getHeadIndexValue(0, member, "CustomerName")))
		$("#mp").val(getHtmlString(getHeadIndexValue(0, member, "mp")))
		memberId=getHtmlString(getHeadIndexValue(0, member, "memberId"));
		}
	}
});

function addInfo(){
	var name = $("#name").val();
	var mp = $("#mp").val()
	var num = $("#num").val()
	var memo = $("#memo").val()
	var time = $("#test_default").val();
	if(IsEmpty(time)){
		alert("预约时间不能为空")
		return false;
	}
	var dateTime = "" ;
	var list = time.split(" ");
	if(list.length==3){
		var year = list[0].split("/");
		if(year.length==3){
			dateTime+=year[2]+"-"
			dateTime+=year[0]+"-";
			dateTime+=year[1]+" ";
		}
		var ti = list[1].split(":")
		if(list[2]=="PM"){
			dateTime+= (12+ parseInt(ti[0]))+":"
			dateTime+=ti[1]
		}else{
			dateTime = list[1]
		}
		if(!checkNull(name, "姓名", "name")||!checkNull(mp, "手机", "mp")){
			return false;
		}
		var head = new Array("CustomerName","CustomerID","ShopID","LinkPhone","OrderDate","License","memo")		
		var data = new Array(name,memberId,_shopId,mp,dateTime,num,memo)
		var params= _getJsonParseInsertStr(head, data);
		var dt=_insertInfoNoSucceedMessage("../../../overServiceRecord/insert/insertInfo", {'data':params});
		if(dt.state==0){
			alert("预约成功")
			restForm();
		}else{
			alert("预约失败")
		}
		
	}
}

function restForm(){
	$("#test_default").val("");
	$("#num").val("")
	$("#memo").val("")
	$("#mp").val("");
	$("#name").val("")
}

</script>
</head>

<body>
<div class="wrapper">
  <div class="container">
  <div class="placeTit">宏博预约</div>
        <div class="person">
            姓名<span class="red">*</span><br>
            <input name="custName" id="name" type="text" class="txt">
        </div>
        <div class="person">
            手机号<span class="red">*</span><br>
            <input name="mp" id="mp" type="text" class="txt">
        </div>
        <!--时间插件start-->
        <div class="commonDateTime person">
          <div style="display:none;">
            <label for="demo">Demo</label>
            <select name="demo" id="demo" class="changes">
              <option value="time" >Time</option>
              <option value="date">Date</option>
              <option value="datetime" selected>Datetime</option>
              <option value="tree_list" >Tree List</option>
              <option value="image_text" >Image & Text</option>
              <option value="select" >Select</option>
              <!--Demos-->
            </select>
          </div>
        <!--时间插件over-->
          <p id="demo_default" class="demos">
            <span class="titTxt">预约时间：</span>
            <input type="text" name="test_default" id="test_default" class="txt test_default" readonly />
          </p>
          <!--Html--> 
        </div>
        <div class="person">
            人数<span class="red">*</span><br>
            <input name="num" id="num" type="text" class="txt">
        </div>
        <div class="person">
            备注	<br>
            <textarea id="memo"></textarea>
        </div>
        <div class="give">
            <input type="button" value="立即预约" class="giveBtn" onclick="addInfo()">
        </div>
  </div>
</div>
</body>
</html>
